package cn.sherer.beans;

import java.io.Serializable;

/**
 * 分页
 */
public class Page implements Serializable {
    private final long total;
    private final int count;
    private final int pages;
    private final Object list;

    public Page(long total, int count, Object list) {
        this.total = total;
        this.count = count;
        this.pages = (int) (total % count == 0 ? total / count : (int) (total / count) + 1);
        this.list = list;
    }

    public long getTotal() {
        return total;
    }

    public int getCount() {
        return count;
    }

    public int getPages() {
        return pages > 0 ? pages : 1;
    }

    public Object getList() {
        return list;
    }

    @Override
    public String toString() {
        return "Page{" + "total=" + total + ", count=" + count + ", pages=" + pages + ", list=" + String.valueOf(list) + "}";
    }
}
